package dao

import (
	"soul/initiate"
	"soul/model"
)

func AddRoom(id int) (room model.Room) {
	room = model.Room{
		RoomId: id,
	}
	err := initiate.DB.Create(&room).Error
	if err != nil {
		return model.Room{}
	}
	return room
}

func CreateRoom(id int) (room model.RoomUser) {
	room = model.RoomUser{
		UerId: id,
	}
	err := initiate.DB.Create(&room).Error
	if err != nil {
		return model.RoomUser{}
	}
	return room
}

func DeleteRoom(id int) (room model.RoomUser) {

	err := initiate.DB.Where("user_id =?", id).Delete(&room).Error
	if err != nil {
		return model.RoomUser{}
	}
	return room
}

func DelRoomId(id int) (room model.RoomUser) {
	err := initiate.DB.Where("room_id =?", id).Delete(&room).Error
	if err != nil {
		return model.RoomUser{}
	}
	return room
}
